package fishinpool;

public class MinDistance {
    private int[] points;
    public MinDistance(int ... points){
        this.points = points;
    }
        
    public int calcMinDistanse(int minPoint) {
        int min = 0;
        for(int point : points) {
            if (Math.abs(point - minPoint) < min) {
                min = Math.abs(point - minPoint);
            }
        }
        return min;
    }
    
    public int calcMinDistance(int minPoint){
        int min = 0;
        for(int point : points){
            if(calcDistance(point, minPoint) < min){
                min = calcDistance(point, minPoint);
            }            
        }
        return min;
    }
    
    public int calcDistance(int point, int minPoint){
        return Math.abs(point - minPoint);
    }
}

